fastlane_version "1.110.0"

default_platform :ios


scheme = “sanda”

def prepare_version(options)
    increment_version_number(
        version_number: options[:version]
    )

    increment_build_number(
        build_number: options[:build]
    )
end




  desc "Deploy a new version to the App Store"
  lane :appstore do |options|
    # match(type: "appstore")
    # snapshot

    prepare_version(options)

    full_version = options[:version] + '_' + options[:build]

    gym(scheme: "#{scheme}", 
      workspace: "#{scheme}.xcworkspace",
      silent: true,
      clean: true, 
      output_directory: "./build", 
      output_name: "#{scheme}_#{full_version}.ipa" ,
      configuration: "Release") # 编译打包 ipa 文件

    deliver(force: true, 
      skip_screenshots:true, 
      skip_metadata: true)    # 不上传截屏文件和元数据。

    # frameit
  end



platform :ios do
  before_all do
    # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
    cocoapods
    
  end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    # match(type: "appstore") # more information: https://codesigning.guide
    gym # Build your app - more options available
    pilot

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md

# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
